package com.enfry.common.util.config;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

public class LoadProperties {
	
	public static Properties load(String file) throws Exception{
		URL url  = ClassLoaderUtils.getResource(file, LoadProperties.class);
		return load(url);
	}
	
	public static Properties load(URL url) throws Exception{
		if(url==null){
			throw new IllegalArgumentException("请指定配置文件路径");
		}
		Properties prop = new Properties();
		prop.load(url.openStream());
		return prop;
	}
	
	public static String getSystemdefaultValue (String key,String filename) {
		LoadProperties loadProp = new LoadProperties();
		InputStream in = loadProp.getClass().getResourceAsStream(filename);
		Properties prop = new Properties();
		try {
			prop.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return prop.getProperty(key, "none");
	}
}
